﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HCFramework.API.LINQ;

namespace HCFramework.Master.Normal
{
    public partial class UsrSetTitle : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Trang trang = C.TrangController.GetCurrentTrangOrInsert();
                txtTitle.Text = trang.Title;
                txtMeta.Text = trang.Meta;
                txtDescription.Text = trang.Description;
            }
        }



        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            HCDataContext dc = new HCDataContext();
            Trang trang = C.TrangController.GetCurrentTrangOrInsert(dc);
            trang.Title = txtTitle.Text;
            trang.Meta = txtMeta.Text;
            trang.Description = txtDescription.Text;
            C.TrangController.Update(trang, dc);
            Response.Redirect(Request.Url.AbsoluteUri);
        }
    }
}